<template>
  <view>
    <view class="u-padding-20"></view>
    <view class="u-padding-30">
      <u-button type="error" @click="logout">退出登录</u-button>
    </view>

  </view>
</template>

<script>
import {removeToken, removeUserInfo} from "../../common/auth";

export default {
  data() {
    return {

    };
  },
  methods: {
    logout(){
      this.$u.api.logout().then(res => {
        if (res.code === 200){
          removeToken();
          removeUserInfo();
          this.$store.commit('SET_ROLE', "");
          this.$store.commit('SET_ID', "");
          this.$store.commit('SET_NAME', "");
          this.$store.commit('SET_NUM', "");
          this.$store.commit('SET_EMAIL', "");
          this.$store.commit('SET_AVATAR', "");
          uni.reLaunch({
            url: '/pages/login/login'
          })
        }
      })
    }
  }
}
</script>

<style lang="scss">

</style>
